package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.service.BpInvestigateConfigService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.enums.Status;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 隐患排查配置
 */

@RestController
@RequestMapping("/bp/bp-investigate-task-config")
@Api(tags = "排查任务和记录")
public class BpInvestigateConfigController {

    @Autowired
    BpInvestigateConfigService configService;

    @GetMapping("/list")
    @ApiOperation(value = "获取配置列表")
    public ResultBean list() {
        return ResultBean.success(configService.findAll());
    }

    @GetMapping("/edit")
    @ApiModelProperty(value = "编辑配置")
    public ResultBean edit(Long id,String status) {
        int i = configService.editConfigByName(id, status);
        return i > 0 ? ResultBean.defaultSuccessResult() : ResultBean.fail(Status.FAILED);
    }

    @GetMapping("/getByName")
    @ApiModelProperty(value = "获取单条配置")
    public ResultBean getByName(String name) {
        return ResultBean.success(configService.getStatusByName(name));
    }

}
